package cn.easy.jacob.utils;

import org.apache.commons.io.FileUtils;
import org.apache.rocketmq.common.message.MessageExt;

import java.io.File;
import java.io.IOException;

public class BaseUtils {

    public static String getFile(String fileUploadDir, String fmt, MessageExt messageExt){
        String srcPath = fileUploadDir + File.separator + System.currentTimeMillis() + fmt;
        File srcfile = new File(srcPath);
        try {
            FileUtils.writeByteArrayToFile(srcfile, messageExt.getBody());
        } catch (IOException e) {
            e.printStackTrace();
        }
        return srcPath;
    }
}
